//
//  yuepianController.m
//  pacc
//
//  Created by 测试 on 2018/6/6.
//  Copyright © 2018年 测试. All rights reserved.
//

#import "yuepianController.h"
#import <JWNetAutoCache/JWCacheURLProtocol.h>
#import "iflyMSC/IFlyMSC.h"
#import "ISRDataHelper.h"
#import "touchTextView.h"
#import "IATConfig.h"
@interface yuepianController ()<UIWebViewDelegate,IFlySpeechRecognizerDelegate,UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *myWebView;
@property (nonatomic, strong) IFlySpeechRecognizer *iFlySpeechRecognizer;
//不带界面的识别对象
@property(nonatomic,strong) NSString *resultStringFromJson;
/**当前是否可以进行录音*/
@property(nonatomic,assign) BOOL isStartRecord;
/**是否已经开始播放*/
@property(nonatomic,assign) BOOL ishadStart;
@property(nonatomic,assign) BOOL isStop;
@property(nonatomic,assign) NSInteger temNum;

@property (strong, nonatomic) NSURLConnection *connection;
@property (strong, nonatomic) NSURLCache *urlCache;
@property (strong, nonatomic) NSURL *url;
@property (strong, nonatomic) NSMutableURLRequest *request;
@property (strong, nonatomic)  UITextView *myTextView;
@property(nonatomic,assign)BOOL  selected;
@property(nonatomic,assign)BOOL  isJianchasuojian;

@property(nonatomic,strong)UIBarButtonItem * voiceButton;

@property(nonatomic,strong)UIView * maskLayer;
@property(nonatomic,strong)UIView * choseview;
@property(nonatomic,strong)UIButton * rightBtn;
@end

@implementation yuepianController

- (void)viewDidLoad {
    [super viewDidLoad];
    _isJianchasuojian = YES;
    [self initRecognizer];
    if (_canYuyin) {
        [self creatNavRightBtn];
    }
    self.title = @"阅片";
    NSURL *url = [NSURL URLWithString:_yuepianURL];//创建URL
    NSLog(@"_yuepianURL==%@",_yuepianURL);
    NSURLRequest* request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:10.0];//创建
    [_myWebView loadRequest:request];
    //讯飞
    self.isStartRecord = YES;
    //初始化字符串,否则无法拼接
    self.resultStringFromJson = @"";
    CGRect btnRect = CGRectMake(20, 200, 100, 100);
    UIButton *btn = [[UIButton alloc] initWithFrame:btnRect];
    btn.backgroundColor = [UIColor orangeColor];
    [btn setTitle:@"语音" forState:UIControlStateNormal];
//    [self.view addSubview:btn];
    
    UILongPressGestureRecognizer *longpress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressActionFromLongPressBtn:)];
    longpress.minimumPressDuration = 0.1;
//    [btn addGestureRecognizer:longpress];
    
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    //设置图片
    UIImage *imageForButton = [UIImage imageNamed:@"back"];
    [button setImage:imageForButton forState:UIControlStateNormal];
    [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    //设置文字
    NSString *buttonTitleStr = @"任务详情";
    
    [button setTitle:buttonTitleStr forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:15];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    UIBarButtonItem *choseButton = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.leftBarButtonItem = choseButton;
  
    touchTextView * myTextView = [[touchTextView alloc]initWithFrame:CGRectMake(ScreenWidth*0.4, 0, ScreenWidth*0.6, 100)];
    myTextView.backgroundColor = [UIColor whiteColor];
//    myTextView.userInteractionEnabled = NO;
    [self.view addSubview:myTextView];
    _myTextView = myTextView;
    _myTextView.delegate = self;
    myTextView.alpha = 0.6;
    myTextView.hidden = YES;
   
     _myTextView.text = _jianchasuojianStr;
//    _zhenduanyijianStr = @"";
}
-(void)viewWillDisappear:(BOOL)animated{
    __weak typeof(self) weakself = self;
    if (weakself.myyuepianBlock) {
        weakself.myyuepianBlock(_jianchasuojianStr,_zhenduanyijianStr);
    }
    _choseview.hidden = YES;
}
- (void)addMaskLayer{
    // 添加遮罩
    _maskLayer = [UIView  new];
    [_maskLayer setFrame:[[UIScreen mainScreen] bounds]];
    [_maskLayer setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3]];
    [self.view addSubview:_maskLayer];
}

- (void)action_removeMask{
    // 移除全屏点击事件
    [_maskLayer removeFromSuperview];
}
#pragma mark --rightBtn--
-(void)creatNavRightBtn{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    _rightBtn = button;
//    button.backgroundColor = [UIColor whiteColor];
//    button.layer.cornerRadius = 5;
    //设置图片
    UIImage *imageForButton = [UIImage imageNamed:@"yuyinxuanze"];
    [button setBackgroundImage:imageForButton forState:UIControlStateNormal];
    [button addTarget:self action:@selector(choseVoice) forControlEvents:UIControlEventTouchUpInside];
    //设置文字
    NSString *buttonTitleStr = @"检查所见  ";
    [button setTitleEdgeInsets:UIEdgeInsetsMake(0,0, 0, 10)];
    [button setTitle:buttonTitleStr forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:15];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    UIBarButtonItem *choseButton = [[UIBarButtonItem alloc] initWithCustomView:button];

    UIView * choseview = [[UIView alloc]initWithFrame:CGRectMake(ScreenWidth-103-60, 30, 98, 60)];
    choseview.backgroundColor = [UIColor whiteColor];
    choseview.layer.cornerRadius = 10;
    [my_AppDelegate.window addSubview:choseview];
    _choseview = choseview;
    _choseview.hidden = YES;
    
    UIButton * choseButton1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, choseview.width, choseview.height/2-1)];
    [choseButton1 setTitle:@"检查所见   " forState:UIControlStateNormal];
    [choseButton1 setFont:[UIFont systemFontOfSize:15]];
    [choseButton1 setTitleColor:basetextColor forState:UIControlStateNormal];
    [choseButton1 addTarget:self action:@selector(chosebuttonClick1) forControlEvents:UIControlEventTouchUpInside];
    [choseview addSubview:choseButton1];
    
    UIButton * choseButton2 = [[UIButton alloc]initWithFrame:CGRectMake(0, choseview.height/2, choseview.width, choseview.height/2+1)];
    [choseButton2 setTitle:@"诊断意见   " forState:UIControlStateNormal];
    [choseButton2 setFont:[UIFont systemFontOfSize:15]];
    [choseButton2 setTitleColor:basetextColor forState:UIControlStateNormal];
    [choseButton2 addTarget:self action:@selector(chosebuttonClick2) forControlEvents:UIControlEventTouchUpInside];
    [choseview addSubview:choseButton2];
    
    UIBarButtonItem * voiceButton= [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"kaishiluyin"] style:UIBarButtonItemStylePlain target:self action:@selector(startVoice)];
    _voiceButton = voiceButton;
    [voiceButton setTintColor:[UIColor whiteColor]];
    [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:voiceButton,choseButton,nil]];
}
-(void)chosebuttonClick1{
    _choseview.hidden = YES;
    [_rightBtn setTitle:@"检查所见" forState:UIControlStateNormal];
    _isJianchasuojian = YES;
    _myTextView.text = _jianchasuojianStr;
}
-(void)chosebuttonClick2{
    _choseview.hidden = YES;
    [_rightBtn setTitle:@"诊断意见" forState:UIControlStateNormal];
    _isJianchasuojian = NO;
    _myTextView.text = _zhenduanyijianStr;
}
-(void)back{
    if (!_isStartRecord) {
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"您当前处于录音状态,请先结束录音"message:nil preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *saveAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }];
        [alertController addAction:saveAction];
        [self.navigationController presentViewController:alertController animated:YES completion:nil];
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
}
-(void)choseVoice{
    if (!_isStartRecord) {
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"您当前处于录音状态,请先结束录音"message:nil preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *saveAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }];
        [alertController addAction:saveAction];
        [self.navigationController presentViewController:alertController animated:YES completion:nil];
    }else{
        _choseview.hidden = NO;
    }
//    [self addMaskLayer];
//    [self.view bringSubviewToFront:_choseview];
}
-(void)startVoice{
    if (!_choseview.hidden) {
        return;
    }
    _myTextView.hidden = NO;
    _selected = !_selected;
    _temNum = 1;
    //设置音频来源为麦克风
    [_iFlySpeechRecognizer setParameter:IFLY_AUDIO_SOURCE_MIC forKey:@"audio_source"];
    //设置听写结果格式为json
    [_iFlySpeechRecognizer setParameter:@"json" forKey:[IFlySpeechConstant RESULT_TYPE]];
    [_iFlySpeechRecognizer setDelegate:self];
    if (self.isStartRecord) {
        [_voiceButton setImage:[UIImage imageNamed:@"tingzhiluyin"]];
//        if(_iFlySpeechRecognizer == nil)
//        {
//            [self initRecognizer];
//        }
//
//        [_iFlySpeechRecognizer cancel];
//
//        //Set microphone as audio source
//        [_iFlySpeechRecognizer setParameter:IFLY_AUDIO_SOURCE_MIC forKey:@"audio_source"];
//
//        //Set result type
//        [_iFlySpeechRecognizer setParameter:@"json" forKey:[IFlySpeechConstant RESULT_TYPE]];
//
//        //Set the audio name of saved recording file while is generated in the local storage path of SDK,by default in library/cache.
//        [_iFlySpeechRecognizer setParameter:@"asr.pcm" forKey:[IFlySpeechConstant ASR_AUDIO_PATH]];
//
//        [_iFlySpeechRecognizer setDelegate:self];
//         self.isStartRecord = NO;
//        BOOL ret = [_iFlySpeechRecognizer startListening];
        if (self.isStartRecord) {
            self.resultStringFromJson = @"";
            //启动识别服务
            [self.iFlySpeechRecognizer startListening];
            self.isStartRecord = NO;
            self.ishadStart = YES;
            self.isStop = NO;
        }
    }else{
        self.isStop = YES;
        [self.iFlySpeechRecognizer stopListening];
    }
}
-(void)alert{
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"您的本段录音已完成,请选择"message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction *saveAction = [UIAlertAction actionWithTitle:@"保存并返回" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self.navigationController popViewControllerAnimated:YES];
    }];
    UIAlertAction *continueAction = [UIAlertAction actionWithTitle:@"继续录音" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

    }];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"重新录音" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        if (self->_isJianchasuojian) {
            self->_myTextView.text = self->_jianchasuojianStr = @"";
        }else self->_myTextView.text = self->_zhenduanyijianStr = @"";
    }];
    
    [alertController addAction:saveAction];
    [alertController addAction:continueAction];
    [alertController addAction:cancelAction];
    [self presentViewController:alertController animated:YES completion:nil];
}
- (void)dealloc{
    if (!_isStartRecord) {
        return;
    }
}
-(void)textViewDidChange:(UITextView *)textView{
    if (_isJianchasuojian) {
        _jianchasuojianStr = textView.text;
    }else{
        _zhenduanyijianStr = textView.text;
    }
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
    _choseview.hidden = YES;
}
-(void)viewDidDisappear:(BOOL)animated{
    [SVProgressHUD dismiss];
}
-(void)test{
    //从请求中获取缓存输出
    NSCachedURLResponse *response =[self.urlCache cachedResponseForRequest:self.request];
    //判断是否有缓存
    if (response != nil){
        NSLog(@"如果有缓存输出，从缓存中获取数据");
        [self.request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
    }
    [self.myWebView loadRequest:self.request];
    
    self.connection = nil;
    
    NSURLConnection *newConnection = [[NSURLConnection alloc] initWithRequest:self.request
                                                                     delegate:self
                                                             startImmediately:YES];
    self.connection = newConnection;
}

-(void)loadData{
    
    NSMutableDictionary *dic =[NSMutableDictionary dictionary];
    NSString *str =[NSString stringWithFormat:@"orderget"];
    
    [dic setValue:_zid forKey:@"orderId"];
    [dic setValue:my_AppDelegate.token forKey:@"token"];
    [NetWorking startPOSTRequestWithUrl:str parameters:dic logMes:@"阅片订单详情" show:NO success:^(NSDictionary *data) {
        [SVProgressHUD dismiss];
        NSDictionary *temdic = [data objectForKey:@"data"];
        if ([temdic isEqual:[NSNull null]]) {
            [SVProgressHUD showErrorWithStatus:@"暂无图片"];
            dispatch_after(1.0, dispatch_get_main_queue(), ^{
                [self.navigationController popViewControllerAnimated:YES];
            });
            return ;
        }
        NSArray * arr = [temdic objectForKey:@"orderPac"];
        dispatch_async(dispatch_get_main_queue(), ^{
            if (arr.count) {
                NSDictionary *dicc = arr[0];
                NSString *urlStr = [dicc objectForKey:@"pacUrl"];
                if ([urlStr isEqual:[NSNull null]]) {
                    [SVProgressHUD showErrorWithStatus:@"暂无图片"];
                    dispatch_after(1.0, dispatch_get_main_queue(), ^{
                        [self.navigationController popViewControllerAnimated:YES];
                    });
                    return ;
                }
                self->_yuepianURL = urlStr;
                NSURL *url = [NSURL URLWithString:self->_yuepianURL];//创建URL
                NSURLRequest* request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:20.0];
                [self->_myWebView loadRequest:request];
            }else{
                [SVProgressHUD showErrorWithStatus:@"暂无图片"];
                dispatch_after(1.0, dispatch_get_main_queue(), ^{
                    [self.navigationController popViewControllerAnimated:YES];
                });
            }
        });
    } failure:^(NSError *error) {
        [SVProgressHUD showErrorWithStatus:@"暂无图片"];
        dispatch_after(1.0, dispatch_get_main_queue(), ^{
            [self.navigationController popViewControllerAnimated:YES];
        });

    }];
}
-(void)webViewDidStartLoad:(UIWebView*)webView {
    [SVProgressHUD showWithStatus:@"加载中"];
}//当网页视图已经开始加载一个请求后，得到通知。
-(void)webViewDidFinishLoad:(UIWebView*)webView{
    [SVProgressHUD dismiss];
}//当网页视图结束加载一个请求之后，得到通知。
-(void)webView:(UIWebView*)webView DidFailLoadWithError:(NSError*)error{
}//当在请求加载中发生错误时，得到通知。会提供一个NSSError对象，以标识所发生错误类型。


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//请求的过程打印出来
- (void)  connection:(NSURLConnection *)connection
  didReceiveResponse:(NSURLResponse *)response{
    NSLog(@"将接收输出");
}
- (NSURLRequest *)connection:(NSURLConnection *)connection
             willSendRequest:(NSURLRequest *)request
            redirectResponse:(NSURLResponse *)redirectResponse{
    NSLog(@"即将发送请求");
    return(request);
}
- (void)connection:(NSURLConnection *)connection
    didReceiveData:(NSData *)data{
    NSLog(@"接受数据");
    NSLog(@"数据长度为 = %lu", (unsigned long)[data length]);
}
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection
                  willCacheResponse:(NSCachedURLResponse *)cachedResponse{
    NSLog(@"将缓存输出");
    return(cachedResponse);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
    NSLog(@"请求完成");
}
- (void)connection:(NSURLConnection *)connection
  didFailWithError:(NSError *)error{
    NSLog(@"请求失败");
}

#pragma mark 讯飞
//初始化识别器
-(void)initRecognizer
{
    //recognition singleton without view
    if (_iFlySpeechRecognizer == nil) {
        _iFlySpeechRecognizer = [IFlySpeechRecognizer sharedInstance];
    }
    
    [_iFlySpeechRecognizer setParameter:@"" forKey:[IFlySpeechConstant PARAMS]];
    
    //set recognition domain
    [_iFlySpeechRecognizer setParameter:@"iat" forKey:[IFlySpeechConstant IFLY_DOMAIN]];
    
    _iFlySpeechRecognizer.delegate = self;
    
    if (_iFlySpeechRecognizer != nil) {
        IATConfig *instance = [IATConfig sharedInstance];
        
        //set timeout of recording
        [_iFlySpeechRecognizer setParameter:instance.speechTimeout forKey:[IFlySpeechConstant SPEECH_TIMEOUT]];
        //set VAD timeout of end of speech(EOS)
        [_iFlySpeechRecognizer setParameter:instance.vadEos forKey:[IFlySpeechConstant VAD_EOS]];
        //set VAD timeout of beginning of speech(BOS)
        [_iFlySpeechRecognizer setParameter:instance.vadBos forKey:[IFlySpeechConstant VAD_BOS]];
        //set network timeout
        [_iFlySpeechRecognizer setParameter:@"20000" forKey:[IFlySpeechConstant NET_TIMEOUT]];
        
        //set sample rate, 16K as a recommended option
        [_iFlySpeechRecognizer setParameter:instance.sampleRate forKey:[IFlySpeechConstant SAMPLE_RATE]];
        
        //set language
        [_iFlySpeechRecognizer setParameter:instance.language forKey:[IFlySpeechConstant LANGUAGE]];
        //set accent
        [_iFlySpeechRecognizer setParameter:instance.accent forKey:[IFlySpeechConstant ACCENT]];
        
        //set whether or not to show punctuation in recognition results
        [_iFlySpeechRecognizer setParameter:instance.dot forKey:[IFlySpeechConstant ASR_PTT]];
        
    }
}

//-(IFlySpeechRecognizer *)iFlySpeechRecognizer
//{
//    if (!_iFlySpeechRecognizer) {
//
//    }
//    return _iFlySpeechRecognizer;
//}
//IFlySpeechRecognizerDelegate协议实现

- (IBAction)startClick:(id)sender {
    if(_iFlySpeechRecognizer == nil)
    {
    }
    //    [_iFlySpeechRecognizer cancel];
    
    //设置音频来源为麦克风
    [_iFlySpeechRecognizer setParameter:IFLY_AUDIO_SOURCE_MIC forKey:@"audio_source"];
    //设置听写结果格式为json
    [_iFlySpeechRecognizer setParameter:@"json" forKey:[IFlySpeechConstant RESULT_TYPE]];
    [_iFlySpeechRecognizer setDelegate:self];
    
    BOOL ret = [_iFlySpeechRecognizer startListening];
    
    if (ret) {
        NSLog(@"启动成功");
    }else{
        NSLog(@"启动失败");
    }
}
- (IBAction)stopclick:(id)sender {
    [_iFlySpeechRecognizer stopListening];
}
#pragma mark - 自定义方法

-(void)longPressActionFromLongPressBtn:(UILongPressGestureRecognizer *)longPress
{
    //    NSLog(@"AIAction");
    CGPoint currentPoint = [longPress locationInView:longPress.view];
    
    if (self.isStartRecord) {
        self.resultStringFromJson = @"";
        
        //启动识别服务
        [self.iFlySpeechRecognizer startListening];
        self.isStartRecord = NO;
        self.ishadStart = YES;
        //开始声音动画
        //        [self TipsViewShowWithType:@"start"];
    }
    //如果上移的距离大于60,就提示放弃本次录音
    if (currentPoint.y < -60) {
        //变成取消发送图片
        //        [self TipsViewShowWithType:@"cancel"];
        self.ishadStart = NO;
    }
    else
    {
        if (self.ishadStart == NO) {
            //开始声音动画
            //            [self TipsViewShowWithType:@"start"];
            self.ishadStart = YES;
        }
    }
    if (longPress.state == UIGestureRecognizerStateEnded) {
        self.isStartRecord = YES;
        if (currentPoint.y < -60) {
            [self.iFlySpeechRecognizer cancel];
        }
        else
        {
            [self.iFlySpeechRecognizer stopListening];
        }
        //让声音播放动画消失
        //        [self TipsViewShowWithType:@"remove"];
    }
    
}


//IFlySpeechRecognizerDelegate协议实现
//识别结果返回代理
- (void) onResults:(NSArray *) results isLast:(BOOL)isLast{
//    self.isStartRecord = YES;
    if (_temNum == 2) {
        return;
    }
    NSMutableString *resultString = [[NSMutableString alloc] init];
    NSDictionary *dic = results[0];
    for (NSString *key in dic) {
        [resultString appendFormat:@"%@",key];
    }
    //持续拼接语音内容
    self.resultStringFromJson = [self.resultStringFromJson stringByAppendingString:[ISRDataHelper stringFromJson:resultString]];
    NSLog(@"self.resultStringFromJson = %@",self.resultStringFromJson);
//    _myTextView.text  =self.resultStringFromJson;
   
    if (_isJianchasuojian) {
        _jianchasuojianStr = [_jianchasuojianStr stringByAppendingString:self.resultStringFromJson];
        _myTextView.text = _jianchasuojianStr;
    }else{
         _zhenduanyijianStr = [_zhenduanyijianStr stringByAppendingString:self.resultStringFromJson];
        _myTextView.text = _zhenduanyijianStr;

    }
    _temNum = 2;
   
    NSLog(@"%@\n%@",_jianchasuojianStr,_zhenduanyijianStr);
}
//识别会话结束返回代理
- (void)onError: (IFlySpeechError *) error{
    NSLog(@"error = %@",[error description]);
}

//停止录音回调
-(void)onEndOfSpeech
{
    if (!self.isStop) {
        _temNum = 1;
        //设置音频来源为麦克风
        [_iFlySpeechRecognizer setParameter:IFLY_AUDIO_SOURCE_MIC forKey:@"audio_source"];
        //设置听写结果格式为json
        [_iFlySpeechRecognizer setParameter:@"json" forKey:[IFlySpeechConstant RESULT_TYPE]];
        self.resultStringFromJson = @"";
        [_iFlySpeechRecognizer setDelegate:self];
        [_iFlySpeechRecognizer startListening];
        self.isStartRecord = NO;
        self.ishadStart = YES;
    }else{
        [self->_voiceButton setImage:[UIImage imageNamed:@"kaishiluyin"]];
        [self alert];
        self.isStartRecord = YES;
        if (![self.resultStringFromJson isEqualToString:@""]) {
        }
    }
}

//开始录音回调
-(void)onBeginOfSpeech
{
    self.isStartRecord = NO;
    NSLog(@"开始录音");
}

//音量回调函数
-(void)onVolumeChanged:(int)volume
{
//    NSLog(@"音量回调");
    
}

//会话取消回调
-(void)onCancel
{
    NSLog(@"取消本次录音");
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
